package com.cskaoyan;

import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/05/17 17:40
 *
 * @author ciggar
 */
public class JDBCDemo {


    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        // 注册驱动
//        Class.forName("com.mysql.jdbc.Driver");
        DriverManager.registerDriver(new Driver());


        // 获取连接
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/40th?useSSL=false&characterEncoding=utf8",
                "root","123456");


        // 获取statement对象
        Statement statement = connection.createStatement();


        // 执行sql语句
        int affectedRows = statement.executeUpdate("insert into account values (10,'马冬梅',200)");


        // 解析结果集
        System.out.println(affectedRows);

        // 关闭资源
        statement.close();
        connection.close();


    }

}
